<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>


<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>

<%@page import="com.crossriver.crgis.database.model.Application_C_of_O"%>
<%@page import="com.crossriver.crgis.database.service.Application_C_of_OLocalServiceUtil"%>
<%@page import="com.crossriver.crgis.database.model.Supporting_Document"%>
<%@page import="com.crossriver.crgis.database.service.Supporting_DocumentLocalServiceUtil"%>

<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>


<portlet:defineObjects />

<div id="main">
	<h1>Downloads</h1>
  <div class="content"> 
  
	    <p>There are two types of downloads that you can do on this page.</p>
	    
	    <p>
	    
	    1) You can download the supporting documents that you submitted for all the applications
	    you submitted to the Cross River State Geographic Agency (CRGIA). 
	    
	    <!-- this will show if there are documents -->
	    Below are the supporting documents:
	    </p>
	    <%
	    
	    ThemeDisplay themeDisplay = (ThemeDisplay) request
	    .getAttribute(WebKeys.THEME_DISPLAY);
	    
    List<Supporting_Document> suppDocs = null;
    
    String userId = "" + themeDisplay.getUserId();
    System.out.println("userId >>" + userId);
    List<Application_C_of_O> applications = Application_C_of_OLocalServiceUtil.
			getApplication_C_of_OByUserId(userId);
    
    %>
    <% 

	for (Iterator iterator = applications.iterator(); iterator.hasNext();) {
		Application_C_of_O application_C_of_O = (Application_C_of_O) iterator.next();
	
		suppDocs = Supporting_DocumentLocalServiceUtil.getSupporting_DocumentByApplId(application_C_of_O.getApplicationId());
		if(suppDocs.size() == 0){
			System.out.println(application_C_of_O.getApplicationId() + application_C_of_O.getApplicationType());
			
			%>
			No Supporting Document<%=application_C_of_O.getApplicationId() + application_C_of_O.getApplicationType()  %>
			<%
		}else{
			
			System.out.println(application_C_of_O.getApplicationId() + application_C_of_O.getApplicationType());
			
			for (Iterator iterator2 = suppDocs.iterator(); iterator2.hasNext();) {
				Supporting_Document suppDoc = (Supporting_Document) iterator2.next();
			%>
			  There are supporting document<%=application_C_of_O.getApplicationId() + application_C_of_O.getApplicationType()  %>
			<%
			}
		}
		
	}
    
    
    
    %>
    <strong>supporting documents</strong>
    
    
    
    
  	<p>2) You may also download application form, fill and submit in any of our offices.</p>
  	
  	<strong>  Application Forms </strong>
    <p>Right-Click or Option-Click the link below and choose "<strong>Save As...</strong>" to download the file.<br><br></p>
    <p><a href="download.pdf" target="_blank">Individual Application for Certificate of Occupancy</a></p>
    <p><a href="download.pdf" target="_blank">Organisation Application for Certificate of Occupancy</a></p>
    <p><a href="download.pdf" target="_blank">Individual Application for Re-Certification of Certificate of Occupancy</a></p>
    <p><a href="download.pdf" target="_blank">Organisation Application for Re-Certification of Certificate of Occupancy</a></p>
	</div>
</div>
